package com.byedu.course.controller;

import com.byedu.domain.kaosi.Kaosi_QuestionDO;
import com.byedu.kaosi.KaoShiQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Luo on 2017-06-28.
 */
@Controller
@RequestMapping("/kaosi")
public class KaoShiAdminController {
    @Autowired
    private KaoShiQuestionService kaoShiQuestionService;

    @RequestMapping("/list")
    public String kaosi(HttpServletRequest request){
        String m = request.getParameter("m");
        if(StringUtils.isEmpty(m)){
            m = "user";
        }
        List<Kaosi_QuestionDO> kaoShiQuestionDOList = kaoShiQuestionService.getKaoShiQuestionDOList();
        request.setAttribute("m", m);
        request.setAttribute("kaoshiList", kaoShiQuestionDOList);
        return "kaosi/kaosilist";
    }

    @RequestMapping("/addkaosi")
    public String addkaosi(HttpServletRequest request){
        String m = request.getParameter("m");
        List<Kaosi_QuestionDO> kaoShiQuestionDOList = kaoShiQuestionService.getKaoShiQuestionDOList();
        request.setAttribute("m", m);
        request.setAttribute("kaoshiList", kaoShiQuestionDOList);
        return "kaosi/addkaosi";
    }

}
